package struct;

import struct.interfaces.TreeNode;

/**
 * 二叉树
 */
public class BinaryTree implements TreeNode {
    private int value;
    private BinaryTree leftNode;
    private BinaryTree rightNode;

    public BinaryTree(int value) {
        this.value = value;
    }

    public BinaryTree(int value, int lValue, int rValue) {
        this.value = value;
        this.leftNode = new BinaryTree(lValue);
        this.rightNode = new BinaryTree(rValue);
    }

    public BinaryTree(TreeNode leftNode, TreeNode rightNode) {
        this.leftNode = (BinaryTree) leftNode;
        this.rightNode = (BinaryTree) rightNode;
    }

    public BinaryTree getLeftNode() {
        return leftNode;
    }

    public BinaryTree setLeftNode(BinaryTree leftNode) {
        this.leftNode = leftNode;
        return this;
    }

    public BinaryTree getRightNode() {
        return rightNode;
    }

    public BinaryTree setRightNode(BinaryTree rightNode) {
        this.rightNode = rightNode;
        return this;
    }

    public int getValue() {
        return value;
    }

    public BinaryTree setValue(int value) {
        this.value = value;
        return this;
    }
}
